﻿using System;
using System.Numerics;

class Tribonacci
{
    static void Main()
    {
        BigInteger first = BigInteger.Parse(Console.ReadLine());
        BigInteger second = BigInteger.Parse(Console.ReadLine());
        BigInteger third = BigInteger.Parse(Console.ReadLine());

        int n = int.Parse(Console.ReadLine());
        BigInteger result = 0;

        if (n == 1)
        {
            result = first;
        }
        else if (n == 2)
        {
            result = second;
        }
        else if (n == 3)
        {
            result = third;
        }
        else
        {
            for (int i = 4; i <= n; i++)
            {
                result = first + second + third;
                first = second;
                second = third;
                third = result;
            }
        }
        Console.WriteLine(result);
    }
}